#include <iostream>
#include <fstream>

//this define can avoid some logs which you don't need to care about.
#define LOGGER_LEVEL LL_WARN 

#include "../../include/simhash/Simhasher.hpp"//头文件位置
using namespace simhash;

int main(int argc, char** argv)
{
    //配置信息
    Simhasher simhasher("../../include/cppjieba/dict/jieba.dict.utf8",
                        "../../include/cppjieba/dict/hmm_model.utf8",
                        "../../include/cppjieba/dict/idf.utf8",
                        "../../include/cppjieba/dict/stop_words.utf8");
    //需要去重的字符串
    string s("我是蓝翔技工拖拉机学院手扶拖拉机专业的。不用多久，我就会升职加薪，当上总经理，出任CEO，走上人生巅峰。");

    size_t topN = 5;//分词级别
    uint64_t u64 = 0;//hash 值
    vector<pair<string ,double> > res;//分词的容器

    simhasher.extract(s, res, topN);//干了啥,把文本弄进去，处理好文本s 和 容器res

    simhasher.make(s, topN, u64);//计算出映射出的前topN个关键词的simhash值

    cout<< "文本：\"" << s << "\"" << endl;
    cout << "关键词序列是: " << res << endl;
    cout<< "simhash值是: " << u64<<endl;


    //这是自己弄的两个？？？ 转换成64位的
    const char * bin1 = "100010110110";//2进制字符串
    const char * bin2 = "110001110011";

    uint64_t u1, u2;//两个64位的simhash值
    u1 = Simhasher::binaryStringToUint64(bin1);//将64位的二进制转换成unit64_t 的hash值 
    u2 = Simhasher::binaryStringToUint64(bin2); 
    
    cout<< bin1 << "和" << bin2 << " simhash值的相等判断如下："<<endl;
    //isEqual函数默认海明距离是3,小于3 则认为是相似，需要去重,大于3则不用
    cout<< "海明距离阈值默认设置为3，则isEqual结果为：" << (Simhasher::isEqual(u1, u2)) << endl; 

    cout<< "海明距离阈值默认设置为5，则isEqual结果为：" << (Simhasher::isEqual(u1, u2, 5)) << endl; 
    return EXIT_SUCCESS;
}
